package com.jisuan.contract.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jisuan.contract.common.utils.PageResult;
import com.jisuan.contract.common.utils.Query;
import com.jisuan.contract.dao.EmployeeDao;
import com.jisuan.contract.entity.EmployeeEntity;
import com.jisuan.contract.service.EmployeeService;
import org.springframework.stereotype.Service;

import java.util.Map;


@Service("employeeService")
public class EmployeeServiceImpl extends ServiceImpl<EmployeeDao, EmployeeEntity> implements EmployeeService {

    @Override
    public PageResult queryPage(Map<String, Object> params, EmployeeEntity employee)
    {
        LambdaQueryWrapper<EmployeeEntity> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.like(
                employee.getEmployeeName() != null,
                EmployeeEntity::getEmployeeName, employee.getEmployeeName()
        );
        IPage<EmployeeEntity> page = this.page(
                new Query<EmployeeEntity>().getPage(params),
                queryWrapper
        );
        return new PageResult(page);
    }
}